import json

from ronglian_sms_sdk import SmsSDK

accId = '8aaf0708780055cd0178d32c7ca44f7c'
accToken = '56b8ba9bd76f47b4ad2581d9eff7ee04'
appId = '8aaf0708780055cd0178d32c7d7c4f83'


class SendSms(object):
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            cls._instance = super().__new__(cls, *args, **kwargs)

            cls._instance.sms_sdk = SmsSDK(accId, accToken, appId)

        return cls._instance

    def send_message(self, mobile='17627916221', datas=("123", "3"), tid="1"):
        resp = self.sms_sdk.sendMessage(tid, mobile, datas)

        ret = json.loads(resp)

        if ret["statusCode"] == "000000":
            return 1
        else:
            return 0


send_sms = SendSms()
